<%@taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@include file="../WEB-INF/jspf/controlesessao.jspf"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Lista Docentes</title>
        <script type="text/javascript" src="../js/jquery.js" ></script>
        <script type="text/javascript" src="../js/jquery.validate.js"></script>
        <script type="text/javascript" src="../js/jquery.tablescroll.js"></script>
        <script type="text/javascript" src="../js/forms.js"></script>
        <script type="text/javascript" src="../js/jquery-ui-1.8.2.custom.min.js" ></script>
        <link rel="stylesheet" href="../css/ui-lightness/jquery-ui-1.8.2.custom.css">
    <link rel="stylesheet" href="../css/forms.css"></head>

    <body>
            <div id="formulario">
    <h1>Listar Docentes</h1>
        <form name="form" method="post">
            <label class="lbInput">Nome docente</label>
            <input name="nome_docente" value="${fn:escapeXml(param.nome_docente)}">
            <br>
            <input class="submit" type="submit" value="Pesquisar">
        <input type="hidden" id="token" name="token" value="${sessionScope.token}" /> </form>
        <c:choose>
            <c:when test="${!empty param.nome_docente}">
                <sql:query var="query" dataSource="jdbc/dbo_MicrosoftSQLServer">
                    SELECT  * FROM Docentes
                    where nome like upper(?)
                    <sql:param value="${param.nome_docente}%"/>
                </sql:query>
                <br>
                <table class="tablescroll"  cellspacing="0" width="100%"> <thead>
                        <th>Matrícula</th>
                        <th>Nome</th>
                        <th>E-mail</th>
                        <th>Horário</th>
                        <th></th>
                    </thead>
                    <tfoot>
                        <tr>
                            <td colspan="5">
                                ${query.rowCount} registros encontrados
                            </td>
                        </tr>
                    </tfoot>
                    <c:forEach var="row" items="${query.rows}">
                        <tr><td>${row.matricula}</td>
                            <td>${row.nome}</td>
                            <td>${row.email}</td>
                            <td>${row.horario}</td>
                            <td><a class="link_chave" href="fm_update_Docentes.jsp?token=${sessionScope.token}&chave=${row.matricula}">
                                <img src="../imagens/Modify.png" height="24" width="24">
                                </a>
                           </td>
                           
                        </tr></c:forEach>
                    </table>                    
            </c:when>
                    <c:otherwise>
                        <p>Entre com pelo menos um valor</p>
                    </c:otherwise>
        </c:choose>
        </div>

    </body>
</html>
